package com.lzy.pattern.singleton.demo2;

/**
 * @ClassName: Client
 * @Description: 饿汉式单例模式测试
 * @Author: LiuZy
 * @Date: 2022/4/9 19:16
 * @Version: 1.0
 */
public class Client {

    public static void main(String[] args) {
//        Singleton instance1 = Singleton.getInstance();
//        Singleton instance2 = Singleton.getInstance();
//
//        System.out.println(instance1 == instance2);
//        System.out.println(instance1.hashCode());
//        System.out.println(instance2.hashCode());


        for (int i = 0; i < 100; i++) {
            new Thread(new Runnable() {
                @Override
                public void run() {
                    Singleton instance = Singleton.getInstance();
                    System.out.println(instance.hashCode());
                }
            }).start();
        }
    }
}